<?php


namespace App\Services;


class FileService
{
    /**
     * @param $file
     * @return string
     */
    static function get_text_content($file) : string {
        return $file;
    }

    static function search($keywords) : array {
        $elastic = new ElasticSearchService();
        if ($keywords) {

            $query = [
                'bool' => [
                    'should' => [
                        ['match' => ['title' => $keywords]],
                        ['match' => ['content' => $keywords]]
                    ]
                ]
            ];
        } else {
            $query = [];
        }

        return $elastic->search($query);
    }
}
